# -*- coding: utf-8 -*-
"""
Created on Wed Sep 26 22:58:40 2018

@author: cheny
"""

l1 = [1,2,3,4,5,6]
print(id(l1))
del l1[2]
print(id(l1))    #删除后id一样
print(l1)
del l1     #一旦把；列表整个都删除，则不能再调用该列表
#print(id(l1))

#列表连接
l1 = [1,2,3,4,5]
l2 = ["a","b","c"]
l3 = l1 + l2
print(l3)


l4 = l1 * 3  #乘法，相当于列表复制，参考前面的 “*” * 20
print(l4)

#in  包含
c = 3 in l1
print (c)
print(7 not in l1)

#列表的遍历
for item in l1:
    print(item)

b = ["I love Python"]
for item in b:
    print(*item)    #打印出单个字符

#使用 while 遍历，一般不用
i = 0
while i < len(l1):
    print(l1[i])
    i += 1
print(i)

#双层列表
ll = [["one", 1], ["two", 2], ["three", 3]]
for k,v in ll:
    print (k, "-->", v)

ll2 = [["one", 1, "一"], ["two", 2], ["three", 3, 4, 5, 6]]


#列表内涵
a = [1,2,3, 4,5]
b = [i for i in a]
print(b)
c = [i * 10 for i in a]
print (c)

d = [x for x in range(1,11)]
print(d)
e = [m for m in d if m %2 == 0] #带条件
print(e)
f = [i+j for i in a for j in e] #列表嵌套
print(f)

#内置函数
a = [x for x in range(1,100)]
print(len(a))
print(max(a))

s = "hello world"
print(list(s))  #转换成list




